package sketch.shape.arrow;

import java.awt.Graphics2D;
import java.awt.Shape;

import sketch.shape.geom.prim.Point;
import sketch.shape.geom.prim.gVector;

public class OpenArrowHead extends ArrowHead {

	private double angle;

	private double length;

	public OpenArrowHead() {

	}

	public double getAngle() {
		return angle;
	}

	public void setAngle(double angle) {
		this.angle = angle;
	}

	public double getLength() {
		return length;
	}

	public void setLength(double length) {
		this.length = length;
	}

	public Point getHeadSideP1() {
		gVector v = getTail().subtract(getHead()).dir().unitized()
			.rotate(getAngle()).multiply(getLength());
		return getHead().add(v);
	}

	public Point getHeadSideP2() {
		gVector v = getTail().subtract(getHead()).dir().unitized()
			.rotate(-getAngle()).multiply(getLength());
		return getHead().add(v);
	}

	protected void drawHead(Graphics2D g2) {
		Point p1 = getHeadSideP1();
		Point p2 = getHeadSideP2();
		Point p = getHead();
		g2.drawLine(p.intX(), p.intY(), p1.intX(), p1.intY());
		g2.drawLine(p.intX(), p.intY(), p2.intX(), p2.intY());
	}

	public Shape getBound(double GAP) {
		//TODO:
		return super.getBound(GAP);
	}

	public String[][] getFieldValues() {
		return new String[][] {
				{ "HeadPoint", getHead().toString() },
				{ "TailPoint", getTail().toString() },
				{ "Angle", Double.toString(getAngle()) },
				{ "Length", Double.toString(getLength()) }
		};
	}


}
